<?php
echo "计算用户输入两个数据的加减乘除的结果\n";
echo "请输入两个数据，用逗号隔开：\n";
$count = fscanf(STDIN, "%f ,%f %s", $a, $b, $other);
//var_dump($count, $a, $b, $other);  //Ctrl+/  注释/取消注释
if ($count > 2) { //count 代表成功接受的数据个数
    echo "不要在输入的数据后面添加乱七八糟的东西~\n";
} else if ($count < 2) {
    echo "请按要求的格式来输入数据~\n";
}else {//正好输入了两个数据
    $jia = $a + $b;
    $jian = $a - $b;
    $cheng = $a * $b;
    $chu = $a ^ $b;
    echo "$a+$b=$jia\n";
    echo "$a-$b=$jian\n";
    echo "$a*$b=$cheng\n";
    echo "$a^$b=$chu\n";
}

